<template>
  <div class="smart-home">

    <!-- 面包屑 -->
    <el-card class="box-card box-card-bgcolor">
      <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
        <el-breadcrumb-item :to="{ path: '/main/home' }">当前位置：首页</el-breadcrumb-item>
        <el-breadcrumb-item>个人中心</el-breadcrumb-item>
      </el-breadcrumb>
    </el-card>
    <!-- 待处理事项： -->
    <el-card class="box-card box-card-bgcolor">
      <div slot="header" class="clearfix">
        <i class="el-icon-edit-outline icon-home"></i>
        <span class="home-title-text blue">个人信息：</span>
      </div>
      <!-- <div class="text item"> -->
        <!-- <div class="pending-items"> -->
          <el-form ref="form" :model="form" label-width="100px">
            <el-form-item label="用户名">
              <el-input v-model="form.username" name="name2"></el-input>
            </el-form-item>
            <el-form-item label="密码">
              <el-input v-model="form.password" name="password2"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="onSubmit">保存修改</el-button>
              <!-- <el-button>退出登录</el-button> -->
            </el-form-item>
          </el-form>
        <!-- </div> -->
      <!-- </div> -->
    </el-card>
  </div>
</template>

<script>
import {getCookie} from '../assets/js/cookie'
export default {
   data() {
      return {
        form: {
          username: '',
          password: '',
          id:''
        }
      }
    },
    created() {
      this.form.username =  getCookie('userName')
      this.form.password =  getCookie('password')
    },
    methods: {
      onSubmit() {
      // 获取当前管理员id
      var params1 = {
          username:this.form.username,
          password:this.form.password,
        }
       //通过调用该接口获得当前用户的id
        this.$http.get("http://localhost/server/php/server/selectSender.php",{params:params1}).then(res =>{
          console.log('获取管理员res2',res)
          if (res.status == '200') {
            this.form.id = res.data.id.id
          }
        })
        var params = {
          // username1:oldUserName,
          username2:this.form.username,
          // password1:OldPassWord,
          password2:this.form.password
        }
        this.$http.get("http://localhost/server/php/personal.php",{
          id:id,
          equipname: this.equipname,
          equipkind: this.equipkind,
          factory: this.factory
        }).then(res =>{
            if (res.status == '200') {
              if (res.data.code == '1') {
                this.$message.success('修改成功！')
                this.$router.push('equipmentMange')
              }else{
                this.$message.success('修改失败！')
              }
            }
          })

        }
    }
  }
</script>

<style scoped lang="scss">
  @import '@/assets/css/addserver.scss'
</style>
